class Solution
{
public:
    ListNode* reverseList(ListNode* head)
    {
        if (!head || !head->next) return head;
        ListNode* tmp = reverseList(head->next);
        head->next->next = head;
        head->next = nullptr;
        return tmp;
    }
};

class Solution {
public:
    ListNode* mergeTwoLists(ListNode* list1, ListNode* list2)
    {
        if (list1 == nullptr) return list2;
        if (list2 == nullptr) return list1;

        if (list1->val < list2->val)
        {
            list1->next = mergeTwoLists(list1->next, list2);
            return list1;
        }
        else
        {
            list2->next = mergeTwoLists(list1, list2->next);
            return list2;
        }
        //return nullptr;
    }
};
class Solution {
public:
    void hanota(vector<int>& A, vector<int>& B, vector<int>& C)
    {
        dfs(A, B, C, A.size());
    }
    void dfs(vector<int>& x, vector<int>& y, vector<int>& z, int size)
    {
        if (size == 1)
        {
            z.push_back(x.back());
            x.pop_back();
            return;
        }
        dfs(x, z, y, size - 1);
        z.push_back(x.back());
        x.pop_back();
        dfs(y, x, z, size - 1);
    }
};